<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>6.24. Zlib-1.2.3</title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css" media="print" />
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head>
  <body id="lfs" class="6.2">
    <div class="navheader">
      <div class="headertitles">
        <h4>Linux From Scratch - 版本 6.2</h4>
        <h3>第六章 安装系统基础软件</h3>
      </div>
      <ul class="headerlinks">
        <li class="prev">
          <a accesskey="p" href="readline.html" title="Readline-5.1">后退</a>
          <p>Readline-5.1</p>
        </li>
        <li class="next">
          <a accesskey="n" href="autoconf.html" title="Autoconf-2.59">前进</a>
          <p>Autoconf-2.59</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a></li>
      </ul>
    </div>
    <div class="wrap">
      <div class="titlepage">
        <h1 class="sect1">6.24. Zlib-1.2.3</h1>
      </div>
      <div class="package">
        <p>Zlib 软件包包含 zlib 库，很多程序中的压缩或者解压缩程序都会用到这个库。</p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">预计编译时间：</span></strong> <span class="seg">少于 0.1 SBU</span>
            </div>
            <div class="seg">
              <strong><span class="segtitle">所需磁盘空间：</span></strong> <span class="seg">3.1 MB</span>
            </div>
          </div>
        </div>
      </div>
      <div class="installation">
        <div class="titlepage">
          <h2 class="sect2">6.24.1. 安装 Zlib</h2>
        </div>
        <div class="note">
          <div class="admonhead">
            <img alt="[Note]" src="../images/note.png" />
            <h3 class="admontitle">注意</h3>
          </div>
          <div class="admonbody">
            <p>如果在环境变量中指定了 <tt class="envar">CFLAGS</tt> 的话，Zlib 就不能正常编译共享库。如果你想使用自定义的 <tt class="envar">CFLAGS</tt> 环境变量，请在下述整个 configure 命令的过程中始终把 <em class="parameter"><tt>-fPIC</tt></em> 指令加在 <tt class="envar">CFLAGS</tt> 的最前面，结束后还必须再撤销它。</p>
          </div>
        </div>
        <p>为编译 Zlib 做准备：</p>
        <pre class="userinput"><kbd class="command">./configure --prefix=/usr --shared --libdir=/lib</kbd></pre>
        <p>编译软件包：</p>
        <pre class="userinput"><kbd class="command">make</kbd></pre>
        <p>要测试结果，请运行：<strong class="userinput"><tt>make check</tt></strong> 。</p>
        <p>安装共享库：</p>
        <pre class="userinput"><kbd class="command">make install</kbd></pre>
        <p>上面的命令将会在 <tt class="filename">/lib</tt> 目录下安装一个 <tt class="filename">.so</tt> 文件。我们将要移除它并重新连接到 <tt class="filename">/usr/lib</tt> 目录下：</p>
        <pre class="userinput"><kbd class="command">rm -v /lib/libz.so
ln -sfv ../../lib/libz.so.1.2.3 /usr/lib/libz.so</kbd></pre>
        <p>编译静态库(非共享库)：</p>
        <pre class="userinput"><kbd class="command">make clean
./configure --prefix=/usr
make</kbd></pre>
        <p>要测试静态库可以用这个命令：<strong class="userinput"><tt>make check</tt></strong> 。</p>
        <p>安装静态库：</p>
        <pre class="userinput"><kbd class="command">make install</kbd></pre>
        <p>修正静态库的权限：</p>
        <pre class="userinput"><kbd class="command">chmod -v 644 /usr/lib/libz.a</kbd></pre>
      </div>
      <div class="content">
        <div class="titlepage">
          <a id="contents-zlib" name="contents-zlib"></a>
          <h2 class="sect2">6.24.2. Zlib 的内容</h2>
        </div>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">安装的库：</span></strong> <span class="seg">libz.{a,so}</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3><a id="id3683151" name="id3683151"></a>简要描述</h3>
          <table border="0">
            <col align="left" valign="top" />
            <tbody>
              <tr>
                <td><a id="libz" name="libz"></a><span class="term"><tt class="filename">libz</tt></span></td>
                <td><p>包含很多程序都用到的压缩和解压函数 </p></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="readline.html" title="Readline-5.1">后退</a>
          <p>Readline-5.1</p>
        </li>
        <li class="next">
          <a accesskey="n" href="autoconf.html" title="Autoconf-2.59">前进</a>
          <p>Autoconf-2.59</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a>.
        </li>
      </ul>
    </div>
</body></html>
